package com.owg.jigsaw.hierarchy;

public class MutableTypeHierarchy extends TypeHierarchy
{	
	public MutableTypeHierarchy(TypeNode... vals)
	{
		super(vals);
	}
	/**Create a TypeHierarchy using the given Java classes.*/
	public MutableTypeHierarchy(Class<?>... classes)
	{
		super(classes);
	}
	/**Cut editor api*/
	public void add(TypeNode t)
	{
		if(valueMap.containsKey(t.getKey()))
			throw new IllegalArgumentException(t+" cannot be added to "+this+" because it has already been added!");
		values.add(t);
		valueMap.put(t.getKey(), t);
		invalidate();
	}
	/**Cut editor api*/
	public void remove(TypeNode t)
	{
		if(!valueMap.containsKey(t.getKey()))
			throw new IllegalArgumentException(t+" cannot be removed from "+this+" because it does not exist!");
		values.remove(t);
		valueMap.remove(t.getKey());
		invalidate();
	}
}
